package string;

//import sun.tools.java.BinaryClass;

/**
 * 格式化输出一个二进制文件
 */
public class FormatDemo {

    public static void print(byte[] bytes) {
        for (int i = 0; i < bytes.length; i++) {
            if((i & 0xf) == 0)
                System.out.format("\n%04X: ", i);
            System.out.format("%02X ", bytes[i]);
        }
    }

    public static void main(String[] args) {
        byte[] bytes = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
        print(bytes);
    }

}
